<?php
// +----------------------------------------------------------------------
// | snake
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2022 http://baiyf.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: NickBai <1902822973@qq.com>
// +----------------------------------------------------------------------
namespace app\api\model;

use think\Model;

class LiveDataModel extends Model
{
    // 确定链接表名
    protected $table = 'live_data';

    /**
     * 根据搜索条件获取用户列表信息
     * @param $where
     * @param $offset
     * @param $limit
     */
    public function getLiveByWhere($where, $offset, $limit)
    {
        return $this->field($this->table . '.*,xl_shop.shop_name,xl_shop.id as shop_id,xl_shop.area,xl_shop.address')
            ->join('xl_shop', $this->table . '.shop_id = ' . 'xl_shop.id')
            ->where($where)->limit($offset, $limit)->order('id desc')->select();
    }


/**
     * 获取一条记录
     * @param $field 字段
     * @param $where 查询条件
     */
    public function getOneLiveData($field,$where)
    {
        return $this->field($field)->where($where)->find();
    }

    /**
     * 获取一个字段值
     * @param $field 字段
     * @param $where 查询条件
     */
    public function getOneField($field,$where){
        return $this->where($where)->column($field);
    }

}